<template>
  <div class="tagplane">
    <el-tag v-for="(item,index) in taglist" :key="index" @click="selectitem(item)" class="">{{item[name]}}</el-tag>
  </div>
</template>
<script>
export default {
  props: ['loadDatafun', 'param', 'name', 'value', 'property', 'type'],
  data () {
    return { taglist: [] }
  },
  created () {
    this.loadDatafun(this.param).then(res => {
      if (res.code === 0) {
        if (this.property !== undefined) {
          if (this.type === 'json') {
            this.taglist = JSON.parse(res.data[this.property])
          } else {
            this.taglist = res.data[this.property]
          }
        } else {
          this.taglist = res.data
        }
      }
    })
  },
  methods: {
    selectitem (item) {
      this.$emit('selectitem', item)
    }
  }
}
</script>
<style scoped>
.tagplane >>> .el-tag {
  margin: 8px;
}
</style>
